package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.businessmanagement.CompanyEntity;
import com.sgb.kjwl.view.ui.adapter.self.CompanyChangeAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;

import java.util.List;

public class CompanyChangePopWindow extends BasePopWindow {

    private CompanyChangeAdapter goodsTypeAdapter;

    public CompanyChangePopWindow(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_goods_type3;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        RecyclerView recyclerView = holder.getPop().findViewById(R.id.goods_type_list);

        goodsTypeAdapter = new CompanyChangeAdapter(mContext,null);
        goodsTypeAdapter.setItemSelect(true);
        goodsTypeAdapter.setDefItem(-1);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext,1));
        recyclerView.setAdapter(goodsTypeAdapter);

        goodsTypeAdapter.setOnItemClick(new AdapterOnItemClick<CompanyEntity>() {
            @Override
            public void onItemClick(CompanyEntity provinceEntity, int position) {
                onResultClick.result(provinceEntity,null,null);
                dissMiss();
            }
        });

        holder.itemView.findViewById(R.id.bg_pop_gray_layout).setOnClickListener(view -> dissMiss());
    }

    public void setData(List<CompanyEntity> list){
        goodsTypeAdapter.setDatas(list);
    }
}
